import time
from selenium import webdriver
from selenium.webdriver.common.by import By
import os.path

# 打开浏览器
driver = webdriver.Chrome()
# 获取本地路径并请求网址
url = 'file:///' + os.path.abspath('html') + '/注册实例.html'
driver.get(url)

time.sleep(2)
# 点击alert
btn_list = driver.find_elements(By.ID, 'alert')
btn_list[0].click()

# 切换到弹窗
time.sleep(2)
alter = driver.switch_to.alert

# 确定
time.sleep(2)
alter.accept()

# 退出浏览器
time.sleep(2)
driver.quit()